

export const token = {
	set: (data, expires_in) => {
		uni.setStorageSync("token", data)
		uni.setStorageSync("expires_in", expires_in)
	},
	get: () => {
		if (Date.parse(new Date()) > uni.getStorageSync("expires_in")) {
			token.clear()
			userInfo.clear()
			return false
		} else {
		
			return uni.getStorageSync("token")
			
		}

	},
	clear: () => {
		uni.removeStorageSync("token")
		uni.removeStorageSync("expires_in")
	}
}



export const userInfo = {
	set: (data, expires_in) => {
		uni.setStorageSync("userInfo", JSON.stringify(data))
		uni.setStorageSync("expires_in", expires_in)
	},
	get: () => {
		if (Date.parse(new Date()) > uni.getStorageSync("expires_in")) {
			return false
		} else {
			return JSON.parse(uni.getStorageSync("userInfo")) 
		}

	},
	clear: () => {
		uni.removeStorageSync("userInfo")
		uni.removeStorageSync("expires_in")
	}
}


